#include<bits/stdc++.h>
#define int long long
#define ll long long
#define inf 1000000007
using namespace std;
int p[100006];
int pd[100006],pv[100005],pa[100005];
bool pand[100005];
struct mex
{
    int l,r;
    bool operator < (const mex &t)const
    {
        if(r == t.r)
            return r - l + 1 < t.r - t.l + 1;
        return r < t.r;
    }
}quers[100005];
int cnt;
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int T;
    cin >> T;
    while(T--)
    {
        int n,m,L,V,ans = 0;
        bool f2 = 1,f3 = 1;
        int cnt2 = 0;
        cin >> n >> m >> L >> V;
        for(int i = 1;i <= n;i++)
        {
            int d,v,a;
            cin >> d >> v >> a;
            pd[i] = d,pv[i] = v,pa[i] = a;


            // cout << d << ' ' << v << ' ' << a << endl ;
            if(a != 0)
                f2 = 0;
            if(a == 0 && v > V)
            {
                // cout << cnt2 << endl ;
                cnt2 ++;
                // cout << v << ' ' << V << endl ;
            }



            if(a <= 0)
            {
                f3 = 0;
                if(v <= V)
                    continue;
                quers[++cnt] = {d,min(L, d + (v * v - V * V) / 2 / a)};
            }


            if(a > 0)
            {
                if(v > V)
                {
                    quers[++cnt] = {1,L};
                    continue;
                }
                int vmax2 = 2 * a * (L - d) + v * v;
                if(vmax2 <= V * V)
                    continue;
                quers[++cnt] = {L - (vmax2 - V * V) / 2 / a, L};
            }
        }
        for(int i = 1;i <= m;i++)
        {
            cin >> p[i];
        }


        if(f2 == 1)
        {
            if(cnt2 == 0)
                m++;
            cout << cnt2 << ' ' << m - 1 << endl ;
            continue;
        }


        if(f3 == 1)
        {
            int ans = 0;
            for(int i = 1;i <= n;i++)
            {
                if(pd[i] > p[m])
                    continue;
                if((p[m] - pd[i]) * pa[i] * 2  > V * V - pv[i] * pv[i])
                {
                    ans++;
                    continue;
                }
            }
            if(ans == 0)
                m++;
            cout << ans << ' ' << m - 1 << endl ;
            continue;
        }

            
        sort(quers + 1,quers + n + 1);
        int aaaans = 0;
        for(int i = 1;i <= n;i++)
        {
            if(pand[i] == 1)
                continue;
            aaaans++;
            for(int j = i;j <= n;j++)
                if(quers[j].l <= quers[i].r && quers[i].r <= quers[j].r)
                    pand[j] = 1;
        }
        cout << cnt << ' ' << aaaans << endl ;
    }
    return 0;
}//So?